using System;
using System.Collections.Generic;
using System.Text;

namespace Hoshimi
{
    public class CollectorGroup_ReleaseState : State
	{
		#region Singleton

		// Fields
		protected static CollectorGroup_ReleaseState instance;

		// Constructor
		protected CollectorGroup_ReleaseState() : base() { }

		// Methods
		public static CollectorGroup_ReleaseState Instance()
		{
			// Uses "Lazy initialization"
			if( instance == null ) 
				instance = new CollectorGroup_ReleaseState();

			return instance;
		}

		#endregion

		public override bool Play( Unit unit )
		{
			CollectorGroup myGroup = (CollectorGroup) unit;

			// We release all units
			myGroup.ReleaseAllUnits();

			myGroup.RemoveAskedBot();
		
			// We ask father to release the group
			if (myGroup.myFather != null)
			{
				((ComplexCollectorGroup)myGroup.myFather).RemoveGroup(myGroup.GetNeedleLocation());
			}

			return true;
		}
	}
}
